package com.cyk.comicforumjava.demos.web;

import com.cyk.comicforumjava.demos.base.ResponseResult;
import com.cyk.comicforumjava.demos.enits.Post;
import com.cyk.comicforumjava.demos.service.PostService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/Section")

public class SectionController {
    @Autowired
    private PostService postService;

    @GetMapping("/getPostList/{sectionId}")
    public ResponseResult getPostList(@PathVariable String sectionId){
        List<Post> postList=postService.getPostList(sectionId);
        return ResponseResult.success(postList);
    }
    @GetMapping("/getOrderPostList/{sectionId}")
    public ResponseResult getOrderPostList(@PathVariable String sectionId){
        List<Post> postList=postService.getOrderPostList(sectionId);
        return ResponseResult.success(postList);
    }
    @PostMapping("/addPost")
    public ResponseResult addPost(@RequestBody Post post){
        postService.addPost(post);
        return ResponseResult.success();
    }
}
